package com.wamke.service.Impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wamke.mapper.EmployeeMapper;
import com.wamke.pojo.Emplyoee;
import com.wamke.pojo.EmplyoeeDTO;
import com.wamke.pojo.PageBean;
import com.wamke.service.EmplyoeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: wanke
 * @ClassName EmplyoeeServicceImpl
 * @author: WXK
 * @create: 2023-10-20 16:03
 **/
@Service
@Slf4j
public class EmplyoeeServicceImpl implements EmplyoeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    //登录
    public void selectByUsername(String username, String password) {
        employeeMapper.select(username ,password);
    }

    //查询所有数据
    public List<Emplyoee> select() {
        List<Emplyoee> list =  employeeMapper.selectAll();
        return list;
    }

    //条件查询
    public PageBean selectByCondition(EmplyoeeDTO emplyoeeDTO) {
        PageHelper.startPage(emplyoeeDTO.getPage(),emplyoeeDTO.getPageSize());
        Page<Emplyoee> page  = employeeMapper.selectBynameAndGender(emplyoeeDTO);
        return new PageBean(page.getTotal(),page.getResult());
    }

    @Override
    public Emplyoee selectById(Long id) {
        Emplyoee emplyoee = employeeMapper.getById(id);
        return null;
    }

    //修改
    public void update(Emplyoee emplyoee) {
        //TODO
        employeeMapper.update(emplyoee);
    }

    //删除
    public void delete(String id) {
        employeeMapper.delete(id);
    }
}
